package de.lgohlke.serializer.kryo;

import java.nio.ByteBuffer;

import com.esotericsoftware.kryo.serialize.SimpleSerializer;

class GenericSerializer<T>
{
	private final SimpleSerializer<T>	serializer;

	/**
	 * <p>Constructor for GenericSerializer.</p>
	 *
	 * @param serializer a {@link com.esotericsoftware.kryo.serialize.SimpleSerializer} object.
	 * @param <T> a T object.
	 */
	public GenericSerializer(SimpleSerializer<T> serializer)
	{
		this.serializer = serializer;
	}

	/**
	 * <p>test.</p>
	 *
	 * @param input a T object.
	 * @return a T object.
	 */
	public T test(T input)
	{
		ByteBuffer buffer = ByteBuffer.wrap(new byte[1000 * 1000]);
		serializer.write(buffer, input);
		return serializer.read(ByteBuffer.wrap(buffer.array()));
	}
}
